import 'dart:async';

import 'package:base_lib/utils/color_util.dart';
import 'package:flutter/material.dart';
import 'package:rxdart/subjects.dart';

class ThemeGlobal {
  static ThemeGlobal get instance => _getInstance();
  static ThemeGlobal _instance;

  ThemeGlobal._internal();

  static ThemeGlobal _getInstance() {
    if (_instance == null) {
      _instance = new ThemeGlobal._internal();
    }
    return _instance;
  }

  void dispose() {
    theme.close();
  }

  BehaviorSubject<MTheme> theme = BehaviorSubject();

  MTheme themeData = MTheme.normal();

  ThemeGlobal() {
    initTheme();
  }

  void initTheme() async {
    themeData = MTheme.normal();
    theme.add(themeData);
  }
}

class MTheme {
  final ThemeColor themeColor;
  final ThemeFontSize themeFontSize;

  MTheme(this.themeColor, this.themeFontSize);

  MTheme.normal() : this(ThemeColor.normal(), ThemeFontSize.normal());
}

class ThemeColor {
  Color themeLightColor = Colors.lightBlue;
  Color themeColor = ColorUtil.color("#438BEF");
  Color themeDartColor = Colors.blueAccent;
  Color themeAccentColor = Colors.orange;

  Color themeBlackColor = Colors.black;
  Color themeGreyColor = Colors.grey;
  Color themeLightGreyColor = ColorUtil.color("#9F9F9F");
  Color themeWhiteColor = Colors.white;

  Color themeTextColor = Colors.black;
  Color themeTextLightColor = Colors.grey;
  Color themeTextShallowColor = Colors.grey[350];
  Color themeTextWhiteColor = Colors.white;
  Color themeTextBlueColor = Colors.lightBlue;
  Color themeTextDetailColor = ColorUtil.color("#666666");
  Color themeTextTitleColor = ColorUtil.color("#797979");

  Color themeBgColor = ColorUtil.color("#f6f6f6");

  ThemeColor(
      this.themeLightColor,
      this.themeColor,
      this.themeDartColor,
      this.themeAccentColor,
      this.themeTextColor,
      this.themeTextLightColor,
      this.themeTextShallowColor,
      this.themeTextWhiteColor,
      this.themeTextDetailColor,
      this.themeBgColor);

  ThemeColor.normal();
}

class ThemeFontSize {
  double fontSizeMin = 10;
  double fontSizeLittle = 12;
  double fontSizeSmall = 14;
  double fontSizeNormal = 16;
  double fontSizeBig = 18;

  ThemeFontSize.normal();
}
